package com.itheima.thread.等待唤醒机制.快递案例;

import java.util.concurrent.ArrayBlockingQueue;

public class Delivery extends Thread {
    ArrayBlockingQueue<String> box;
    private int count = 10;

    public Delivery(ArrayBlockingQueue<String> arrayBlockingQueue) {
        box = arrayBlockingQueue;
    }


    @Override
    public void run() {
        while (count>0){
            try {
                box.put("快递");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(getName() + "放了一个快递然后离开了,还剩" + (30 - box.size())+ "柜子");
            count--;
        }
        System.out.println(getName()+ "快递送完回家了");
    }
}
